Similar to js() is there a way to add TypeScript d...
# javascript
b
Similar to js() is there a way to add TypeScript definitions?
1
a
Unfortunately, no. Could you please describe your use case? (Maybe we need to think about adding such a thing)
b
I'm looking at something like this
Copy code
interface HelloWorld {
    type: "hello_world";
    payload: {
       greeting: string;
    }
}

interface OrderCreated {
    type: "order_created";
    payload: {
        orderId: string;
        customerId: string;
    }
}

function publish(event: HelloWorld | OrderCreated) {
    // POST to /endpoint {event: "hello_world", body: {...}}
}
it's very difficult to translate that to API to Kotlin since sealed interfaces don't really translate well
sum types are an issue as well
a
Oh, I see. I believe we will fix quite soon the sealed hierarchy translation to the union. But let me also think on the something like
TsType
or somthing like that to inject a specific TypeScript for a declaration
b
there are ofc tougher issues like generics in the form of class X<T ? Something : Elseinfer X> but I think
Copy code
@TsType("\"order_created\"")
private type: String
would cover 80%; still tough to think about how to design the APIs